home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 245 / mag3 / magnify.s < prev    next >
Text File  |  1988-10-10  |  4KB  |  114 lines

  1. adr1      equ    a1
  2. adr2      equ    a2
  3. des_adr1  equ    a4
  4. des_adr2  equ    a5
  5. copy_adr  equ    a6
  6.  
  7.        text
  8.  
  9.     move.l   4(sp),des_adr1    ; The physical screen's address.
  10.     move.l   8(sp),adr1        ; The location where the start of the
  11.                                ; GET bitblock is stored.
  12.     move.l   adr1,adr2         ; Adr1 must be set two bytes ahead
  13.     add.l    #2,adr2           ; ahead of adr1.
  14.  
  15.     add.l    #88,des_adr1      ; The initial offset for the
  16.                                ; destination block.
  17.     move.l   des_adr1,des_adr2   ; Des_adr2 must also be set
  18.     add.l    #2,des_adr2         ; two bytes ahead of des_adr1.
  19.  
  20.  ; This does the actual work...
  21.  
  22.     move.w   #50,d0     ; The number of lines in the GET command.
  23. L0: move.w   #3,d1      ; The main idea behind this program is that
  24. L1: move.w   #1,d2      ; the horizontal bits are copied four times
  25. L2: move.w   #7,d3      ; and then each expanded line is reproduced
  26. L3: cmpi.w   #3,d3      ; three more times.  This expands the image
  27.                         ; vertically four times also.
  28.     bne      skip
  29.     add.l    #2,des_adr1  ; To understand how the horizontal expansion
  30.     add.l    #2,des_adr2  ; works, a short explanation of how the
  31.                           ; medium resolution screen stores its image
  32.                           ; is necessary.
  33.  
  34.     ; In medium-rez only four colors can be displayed (even though all
  35.     ; 512 colors are available) at one time.  Thus each pixel's color
  36.     ; can be set using only two bits.
  37.  
  38. skip:
  39.     move.l   adr1,a0      ; The information for the color of the first
  40.     move.l   des_adr1,a3  ; sixteen pixels is stored in the first two
  41.     jsr      Bit_test     ; words of the screen's memory.  The first pixel's
  42.     move.l   a3,des_adr1  ; color is determined by the MSB ( Most Significant
  43.                           ; Bit ) of the first word and the MSB of the second
  44.     move.l   adr2,a0      ; word.  Each consecutive bit is determined in a
  45.     move.l   des_adr2,a3  ; similar fashion until the Least Significant Bit is
  46.     jsr      Bit_test     ; read.  This program reads two bits at a time and
  47.     move.l   a3,des_adr2  ; duplicates each pair four times.  An example:
  48.  
  49.                           ; The initial settings of the pointers
  50.                           ; adr1 and adr2 and des_adr1 and des_adr2.
  51.  
  52.     sub.w    #1,d3        ; { adr1  }           { adr2  }
  53.     dbra     d3,L3        ; 1001 1100 1110 0101 0100 0001 1100 0010
  54.                           ; |=== 1st  word ===| |=== 2nd word ====|
  55.     add.l    #1,adr1
  56.     add.l    #1,adr2      ; {des_adr1}          {des_adr2}
  57.                           ; 1111 0000 0000 1111 0000 1111 0000 0000
  58.     add.l    #2,des_adr1  ; ...etcetra
  59.     add.l    #2,des_adr2  ; The program keeps track of when the pointers
  60.                           ; need to be moved.  Essentially, that is the
  61.     dbra     d2,L2        ; whole idea.
  62.     add.l    #2,adr1
  63.     add.l    #2,adr2
  64.  
  65.     dbra     d1,L1
  66.     add.l    #4,adr1   ; Skip the GET null bytes
  67.     add.l    #4,adr2
  68.  
  69.  ;
  70.     move.l   des_adr1,copy_adr
  71.     add.l    #96,des_adr1       ; Set the des_adr1 to the next line
  72.     move.w   #2,d4              ; Number of copies
  73. L4: sub.l    #64,copy_adr       ; Set copy_adr to the line's first byte
  74.     move.w   #63,d5                   ; Number of bytes per line
  75. L5: move.b   (copy_adr)+,(des_adr1)+  ; Do it
  76.     dbra     d5,L5                    ; 64 times
  77.     add.l    #96,des_adr1       ; Offset to the next row
  78.     dbra     d4,L4
  79.  
  80.     move.l   des_adr1,des_adr2
  81.     add.l    #2,des_adr2
  82.  
  83.     dbra     d0,L0
  84.  
  85.     rts                      ; Return to GFA Basic
  86.  
  87. Bit_test:
  88.     move.w   d3,d7
  89.     sub.w    #1,d7
  90.  
  91.     btst     d3,(a0)
  92.     bne      Test2       ; Branch if bit 1=1
  93.     btst     d7,(a0)
  94.     bne      Set_01      ; Branch if bit 2=1
  95.  
  96. Set_00: move.b    #$00,(a3)+
  97.     rts
  98.  
  99. Test2:
  100.     btst     d7,(a0)
  101.     bne      set_11      ; Branch if bit 2=1
  102.  
  103. Set_10:  move.b  #$F0,(a3)+
  104.     rts
  105.  
  106. Set_01:  move.b  #$0F,(a3)+
  107.     rts
  108.  
  109. Set_11:  move.b  #$FF,(a3)+
  110.     rts
  111.  
  112.    end
  113.